<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>视频播放</title>
</head>
<link rel="stylesheet" href="//g.alicdn.com/de/prismplayer/2.6.0/skins/default/aliplayer-min.css"/>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="//g.alicdn.com/de/prismplayer/2.6.0/aliplayer-min.js"></script>
<body>
<script type="text/javascript">
    var auth = "";
    var cover = "";
    var vid = "";

    $(function () {
        vid = getUrlParam('videoId');
        $.ajax({
            url: "${ctx}/adv/hkMediaAdv/getPlayInfoAuth",
            type: "GET",
            data: {
                // "videoId": "4c97891518b649f4a0adf666aad705df"
                "videoId": vid
            },
            success: function (res) {
                console.log(res)
                if (res != null) {
                    var json = JSON.parse(res);
                    auth = json.PlayAuth;
                    cover = json.VideoMeta.CoverURL;
                    // videoId = json.VideoMeta.VideoId;

                    var palyerDom = document.createElement('div');
                    palyerDom.id = 'J_prismPlayer';
                    palyerDom.style.width = '1280px';
                    palyerDom.style.height = '700px';
                    palyerDom.className = 'prism-player';
                    var body = document.getElementsByTagName('body');
                    if (body.length) {
                        debugger;
                        body[0].appendChild(palyerDom);
                        var player = new Aliplayer({
                            id: "J_prismPlayer",
                            autoplay: true,
                            width: "1920px",
                            height: "1280px",
                            vid: vid,
                            playauth: auth,
                            cover: cover
                        });
                    }
                }
            }, error: function (res) {
                alert("视频加载出错，请稍后重试.")
            }
        })
    });

    //获取url中的参数
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]);
        return null; //返回参数值
    }

</script>

</body>
</html>
